<template>
	<view>
		<view class="video-list">
			<view class="video-content" v-for="(item, ind) in meals" :key="ind">
				<!-- <view class="video-cover">
					<image :src="item.picUrl" mode="aspectFill"></image>
				</view> -->
				<view class="video-describe">
					<view style="width: 75%;">
						<view class="video-tit">
							套餐名称:{{item.mealName}}
						</view>
						<view class="video-reader">
							套餐时长:{{item.duration}}小时
						</view>
						<view class="video-reader">
							套餐价格:{{item.price}}元
						</view>
					</view>
					<view>
						<view class="cannel" @click="updateMeal(item.id)">
							<text>点击绑定</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import Api from '@/common/api';
	export default {
		components: {
	
		},
		data() {
			return {
				index: 0,
				meals:[],
				deviceId:null,
				storeId:null,
			}
		},
		onLoad(options) {
			let deviceId = options.deviceId;
			this.deviceId = deviceId;
			this.storeId = options.storeId;
			this.getMeals(this.storeId);
		},
		onShow(options) {
			this.getMeals(this.storeId);
		},
		methods: {
			async getMeals(storeId){
				let data = await Api.apiCall('get', Api.meal.getMeals, {
					storeId:storeId
				});
				if(data){
					this.meals = data;
					console.log(this.meals)
				}
			},
			async updateMeal(mealId){
				//id mealId
				let params = {
					id:this.deviceId,
					mealId:mealId
				}
				
				let data = await Api.apiCall('post', Api.qsg.updateMeal+this.deviceId, params);
				
				if(data){
					uni.showModal({
						title: '提示',
						content: '已成功添加到设备.',
						success: function(res) {
							if (res.confirm) {
							} else if (res.cancel) {
					
							}
						}
					});
				}
			},
			addMeal(){
				uni.navigateTo({
					url:'/pages/meal/edit?storeId='+this.storeId
				})
			}
		}
	}
</script>

<style>
	.cannel{
		width: 130rpx;
		height: 40rpx;
		background: #0DA944;
		border-radius: 10rpx;
		font-size: 24rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 40rpx;
		text-align: center;
		margin-top: 60rpx;
	}
	.afrim{
		width: 650rpx;
		height: 80rpx;
		background: #0DA944;
		border-radius: 30rpx;
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 80rpx;
		text-align: center;
		position: fixed;
		bottom: calc(100% - 95%);
		margin-left: 40rpx;
	}
	.priceSign{
		font-size: 24rpx;
	}
	.priceNum{
		font-size: 32rpx;
		font-weight: bold;
	}
	.priceIcon{
		font-size: 24rpx;
	}
	.schoolName{
		width: 750rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		font-size: 50rpx;
		font-weight: bold;
		color: #000000;
	}
	.uni-input{
		padding: 0 24rpx;
	}
	.choese{
		width: 750rpx;
		display: flex;
		box-sizing: border-box;
		padding:0 30rpx;
		color: #888888;
	}
	.dataName{
		height: 60rpx;
	}
	.currentSchool{
		height: 60rpx;
		background: #FFFFFF;
	}
	.video-tit {
		font-size: 30rpx;
		color: #62b074;
		font-weight: bold;
		display: inline-block;
		vertical-align: top;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}
	
	.checkMore text{
		display: block;
		width: 100%;
		height: 60rpx;
		line-height: 58rpx;
		font-size: 24rpx;
		color: #172a89;
		border: 1px solid #172A89;
		text-align: center;
		box-sizing: border-box;
		margin-top: 46rpx;
		border-radius: 50rpx;
	}
	
	.checkMore {
		font-size: 24rpx;
		color: #172a89;
		flex: 1;
	}
	
	.video-price {
		font-size: 30rpx;
		color: #666;
		overflow: hidden;
		display: inline-block;
		vertical-align: top;
		text-align: center;
		box-sizing: border-box;
	}
	
	.video-reader {
		font-size: 24rpx;
		color: #666;
	}
	
	.video-describe {
		display: inline-block;
		vertical-align: top;
		display: flex;
		width: 100%;
		padding-left: 20rpx;
	}
	
	.video-cover {
		width: 100rpx;
		height: 100rpx;
		margin: 30rpx 30rpx 30rpx 0;
		display: inline-block;
		vertical-align: top;
		border-radius: 50%;
		flex: 1;
	}
	
	.video-cover image {
		width: 100rpx;
		height: 100rpx;
		background: #FFFFFF;
		border-radius: 50%;
	}
	
	.video-content {
		width: 690rpx;
		padding: 22rpx 0;
		border: 1rpx solid #f1f1f1;
		box-shadow: 0 0 10px #e6e6e6;
		border-radius: 20rpx;
		box-sizing: border-box;
		display: flex;
		margin-top: 20rpx;
	}
	
	.video-content:last-child {
		border: none;
	}
	
	.video-list {
		width: 750rpx;
		height: auto;
		padding: 0 30rpx;
		box-sizing: border-box;
	}
</style>
